package com.example.home.logistics.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.home.R;
import com.example.home.logistics.bean.ComplaintListBean;

import java.util.List;

public class ComplaintListAdapter extends RecyclerView.Adapter<ComplaintListAdapter.MyHoldy> {
    private Context context;
    private List<ComplaintListBean.RowsBean> list;

    public ComplaintListAdapter(Context context, List<ComplaintListBean.RowsBean> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public MyHoldy onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_comp, null);
        return new ComplaintListAdapter.MyHoldy(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MyHoldy holder, int position) {
        holder.name.setText(list.get(position).getCompany().getName());
        holder.questionType.setText("投诉类型："+list.get(position).getQuestionType());
        holder.description.setText("投诉原因："+list.get(position).getDescription());
    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    public class MyHoldy extends RecyclerView.ViewHolder {
        private TextView name;
        private TextView questionType;
        private TextView description;

        public MyHoldy(@NonNull View itemView) {
            super(itemView);
            name = itemView.findViewById(R.id.name);
            questionType = itemView.findViewById(R.id.questionType);
            description = itemView.findViewById(R.id.description);
        }
    }
}
